<?php
class Web_Form_Password
	extends Zend_Form
{

	public function init()
	{				
	
		$this->setMethod('post');
		$this->setName('passwordForm');

		$password = new Zend_Form_Element_Password('password');
		$password->setLabel('Clave');
		$password->setRequired(true);
		
		$password->addFilter('StripTags');
	    $password->addFilter('StringTrim');
		
	    $password->addValidator('Alnum');
		$password->addValidator(new Zend_Validate_StringLength(5, 20));
		$password->addValidator( new My_Validate_IdenticalField ('password_confirm', 'Confirm Password'));
		$this->addElement($password);
		
		$password_confirm = new Zend_Form_Element_Password('password_confirm');
		$password_confirm->setLabel('Confirmar clave');
		$this->addElement($password_confirm);
				
		$submit = new Zend_Form_Element_Submit('submit');
		$submit->setLabel('Enviar');
		$this->addElement($submit);
	}
	
	public function loadDefaultDecorators()	{
		
		$elements = $this->getElements();
		unset($elements['submit']);
		
		$this->addDecorator('FormElements')
			->addDecorator('HtmlTag', 	array('tag' => 'div', 'class' => 'zend_form'))
			->addDecorator('Form')
			->setElementDecorators(array(
				array('ViewHelper'),
				array('Errors',			array('placement' => 'APPEND')),
				array('Description', 	array('tag' => 'em', 'class' => 'element-description', 'placement' => 'APPEND')),
				array('Label', 			array('separator' => ' ', 'placement' => 'PREPEND')),
				array('HtmlTag', 		array('tag' => 'div', 'class' => 'element')),
				),
				array_keys($elements)
			);	

		$this->setElementDecorators(array(
				array('ViewHelper'),				
				array('HtmlTag', 		array('tag' => 'div', 'class' => 'submit-group')),
				),
				array('submit')
			);
	
	}



}